package com.ittsang.controller;

import com.ittsang.dto.PageDTO;
import com.ittsang.dto.R;
import com.ittsang.dto.UserApplicationDTO;
import com.ittsang.service.ClubService;
import com.ittsang.service.UserApplicationService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/club")
public class ClubController {

    @Resource
    private ClubService clubService;

    @Resource
    private UserApplicationService userApplicationService;

    /**
     *  获取所有社团
     * @param pageDTO
     * @return
     */
    @PostMapping("/getAllClub")
    public R getAllClub(@RequestBody PageDTO pageDTO) {
        return clubService.getAllClub(pageDTO);
    }


    /**
     *  获取社团全部部门
     * @return
     */
    @GetMapping("/getCLubDepByClubId")
    public R getCLubDepByClubId(@RequestParam("clubId") Integer clubId) {
        return clubService.getCLubDepByClubId(clubId);
    }

    /**
     *  用户加入社团，一个用户只能加入一个社团
     * @param userApplicationDTO
     * @return
     */
    @PostMapping("/insertClubUser")
    public R insertClubUser(UserApplicationDTO userApplicationDTO) {
        return userApplicationService.insertClubUser(userApplicationDTO);
    }

}
